package com.stars.empoly.vmodel

import android.app.Application
import android.text.Editable
import android.text.TextUtils
import androidx.databinding.Bindable
import com.stars.empoly.BR
import com.stars.empoly.utils.net.NetEngine
import com.stars.empoly.view.SimpleTextWatcher
import com.trailer.base.base.BRRepository
import com.trailer.base.base.BRViewModel
import com.trailer.base.net.IResp

class HomeSpaceVModel(application: Application) : BRViewModel<BRRepository>(application) {

    @Bindable
    open var k: String? =""
        set(value) {
            field = value
            notifyPropertyChanged(BR.k)
        }


    var oldText = ""
    var textWatcher = object : SimpleTextWatcher() {
        override fun afterTextChanged(s: Editable?) {
            super.afterTextChanged(s)
            var content = s.toString()
            if (!TextUtils.isEmpty(oldText) && content == oldText) {
                return
            }
            oldText = content
            //刷新
            firstReq()


        }

    }



    fun  toReceOrder(info_id: String){
        //到接单界面
//        UiSwitch.bundle(repository().context, GrabDetailsActivity::class.java, Bundle().apply {
//            putString("info_id", info_id)})

    }

    override fun apiFunc(): suspend () -> IResp<*> {
        return {
            NetEngine.service.orderList("0", "10", repository().page)
        }
    }


}
